package com.quan.mall.mapper;

import com.quan.mall.entity.PmsSku;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.quan.commons.core.biz.support.MyBaseMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 商品-SKU信息
 * 
 * @author yhaoquan
 * @email yhaoquan@163.com
 * @date 2021-02-09 11:44:02
 */
public interface PmsSkuMapper extends MyBaseMapper<PmsSku> {

	/**
     * 分页查询列表
     * @param page
     * @param entity
     * @return
     */
    IPage<PmsSku> selectMyPage(IPage<PmsSku> page, @Param("entity") PmsSku entity);

    /**
     * 商品下订单之后更改库存数量
     * @param id
     * @param num
     * @return
     */
    @Update("update pms_sku set stock_num = stock_num-#{num} where id = #{id} and stock_num >= #{num}")
    int decrCount(@Param("id") Long id, @Param("num") Integer num);

}
